{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import snap\n",
    "import time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 2min 21s, sys: 4.23 s, total: 2min 25s\n",
      "Wall time: 2min 25s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#加载数据：http://snap.stanford.edu/data/soc-LiveJournal1.html\n",
    "graph = snap.LoadEdgeList(snap.PNGraph, \"soc-LiveJournal1.txt\", 0, 1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#使用print可以得到一些常见的图的结构等属性\n",
    "snap.PrintInfo(graph, \"Python type PNGraph\", \"info-pngraph.txt\", False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4847571\n",
      "CPU times: user 6 ms, sys: 5 ms, total: 11 ms\n",
      "Wall time: 4.8 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#图中节点个数\n",
    "print(graph.GetNodes())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "68993773\n",
      "CPU times: user 799 ms, sys: 3 ms, total: 802 ms\n",
      "Wall time: 798 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#图中边数\n",
    "print(graph.GetEdges())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4442\n",
      "CPU times: user 1.23 s, sys: 7 ms, total: 1.23 s\n",
      "Wall time: 1.23 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#度为100的节点个数\n",
    "print(snap.CntDegNodes(graph, 100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1785\n",
      "CPU times: user 1.46 s, sys: 2 ms, total: 1.46 s\n",
      "Wall time: 1.46 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#出度为100的节点个数\n",
    "print(snap.CntOutDegNodes(graph, 100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1809\n",
      "CPU times: user 1.37 s, sys: 3 ms, total: 1.37 s\n",
      "Wall time: 1.37 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#入度为100的节点个数\n",
    "print(snap.CntInDegNodes(graph, 100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10009\n",
      "CPU times: user 1.18 s, sys: 1 ms, total: 1.18 s\n",
      "Wall time: 1.18 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#有着最大出度的节点的id\n",
    "print(snap.GetMxOutDegNId(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10029\n",
      "CPU times: user 1.07 s, sys: 4 ms, total: 1.07 s\n",
      "Wall time: 1.07 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#有着最大入度的节点的id\n",
    "print(snap.GetMxInDegNId(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1876\n",
      "CPU times: user 17.1 s, sys: 1e+03 µs, total: 17.1 s\n",
      "Wall time: 17.1 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#Components是弱连通网络集合\n",
    "Components = snap.TCnComV()\n",
    "snap.GetWccs(graph, Components)\n",
    "print(Components.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "24\n",
      "CPU times: user 15.4 s, sys: 0 ns, total: 15.4 s\n",
      "Wall time: 15.4 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#ComponentDist相当于对Components按<弱连通网络中节点数大小>进行了分组\n",
    "ComponentDist = snap.TIntPrV()\n",
    "snap.GetWccSzCnt(graph, ComponentDist)\n",
    "print(ComponentDist.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4843953\n",
      "CPU times: user 14.7 s, sys: 5 ms, total: 14.7 s\n",
      "Wall time: 14.7 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#和节点3在同一个弱连通网路的节点集合\n",
    "CnCom = snap.TIntV()\n",
    "snap.GetNodeWcc(graph, 3, CnCom)\n",
    "# print \"Nodes in the same connected component as node 0:\"\n",
    "# for node in CnCom:\n",
    "#     print node\n",
    "# print('--')\n",
    "print(CnCom.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4843953\n",
      "68983820\n",
      "CPU times: user 1min 8s, sys: 178 ms, total: 1min 9s\n",
      "Wall time: 1min 9s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#最大的弱连通图节点数和边数\n",
    "MxWcc = snap.GetMxWcc(graph)\n",
    "print(MxWcc.GetNodes())\n",
    "print(MxWcc.GetEdges())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.999253646826\n",
      "CPU times: user 17.1 s, sys: 11 ms, total: 17.1 s\n",
      "Wall time: 17.1 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#最大的弱连通图的节点相对大小\n",
    "print(snap.GetMxWccSz(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "971232\n",
      "CPU times: user 47.6 s, sys: 13 ms, total: 47.6 s\n",
      "Wall time: 47.6 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#Components是强连通网络集合\n",
    "Components = snap.TCnComV()\n",
    "snap.GetSccs(graph, Components)\n",
    "print(Components.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "68\n",
      "CPU times: user 40.1 s, sys: 11 ms, total: 40.1 s\n",
      "Wall time: 40.1 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#ComponentDist相当于对Components按<强连通网络中节点数大小>进行了分组\n",
    "ComponentDist = snap.TIntPrV()\n",
    "snap.GetSccSzCnt(graph, ComponentDist)\n",
    "print(ComponentDist.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3828682\n",
      "65825429\n",
      "CPU times: user 2min 39s, sys: 185 ms, total: 2min 39s\n",
      "Wall time: 2min 40s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#最大的强连通图的节点数和边数\n",
    "MxWcc = snap.GetMxScc(graph)\n",
    "print(MxWcc.GetNodes())\n",
    "print(MxWcc.GetEdges())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.789814527729\n",
      "CPU times: user 36.9 s, sys: 92 ms, total: 37 s\n",
      "Wall time: 37 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#最大的强连通图的节点相对大小\n",
    "print(snap.GetMxSccSz(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3665291\n",
      "67046693\n",
      "CPU times: user 2min 33s, sys: 948 ms, total: 2min 34s\n",
      "Wall time: 2min 34s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#有向图的最大双连通图网络的节点数和边数\n",
    "BiCon = snap.GetMxBiCon(graph)\n",
    "print(BiCon.GetNodes())\n",
    "print(BiCon.GetEdges())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "285730264\n",
      "CPU times: user 11min 31s, sys: 671 ms, total: 11min 32s\n",
      "Wall time: 11min 32s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#互连三元祖闭合环个数\n",
    "print(snap.GetTriads(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "closed triads 285730264\n",
      "open triads 6412312961\n",
      "CPU times: user 5min 48s, sys: 326 ms, total: 5min 48s\n",
      "Wall time: 5min 48s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#互连三元祖闭合环个数和非闭合环个数\n",
    "result = snap.GetTriadsAll(graph)\n",
    "print \"closed triads\", result[0]\n",
    "print \"open triads\", result[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "60549807\n",
      "CPU times: user 3min 36s, sys: 0 ns, total: 3min 36s\n",
      "Wall time: 3min 36s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#参与互连三元祖闭合环的边数\n",
    "print(snap.GetTriadEdges(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Aggregation coefficient set grouped by degree 2045\n",
      "average clustering coefficient 0.274241387656\n",
      "closed triads 285730264\n",
      "open triads 6412312961\n",
      "CPU times: user 6min 2s, sys: 338 ms, total: 6min 2s\n",
      "Wall time: 6min 2s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#按度分组聚集系数集合，总平均聚集系数、闭合环个数、非闭合环个数\n",
    "DegToCCfV = snap.TFltPrV()\n",
    "result = snap.GetClustCfAll(graph, DegToCCfV)\n",
    "print \"Aggregation coefficient set grouped by degree\",DegToCCfV.Len()\n",
    "print \"average clustering coefficient\", result[0]\n",
    "print \"closed triads\", result[1]\n",
    "print \"open triads\", result[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "16\n",
      "16\n",
      "CPU times: user 8min 25s, sys: 218 ms, total: 8min 26s\n",
      "Wall time: 8min 26s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#利用广度遍历来求得图的近似直径值\n",
    "#将其看成是无向图\n",
    "print(snap.GetBfsFullDiam(graph, 10, False))\n",
    "#将其看成是有向图\n",
    "print(snap.GetBfsFullDiam(graph, 10, True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6.26989395007\n",
      "6.77949979352\n",
      "CPU times: user 6min 45s, sys: 126 ms, total: 6min 45s\n",
      "Wall time: 6min 45s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#th percentile of the distribution的近似直径值\n",
    "#将其看成是无向图\n",
    "print(snap.GetBfsEffDiam(graph, 10, False))\n",
    "#将其看成是有向图\n",
    "print(snap.GetBfsEffDiam(graph, 10, True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "49735\n",
      "16791\n",
      "CPU times: user 180 ms, sys: 498 ms, total: 678 ms\n",
      "Wall time: 665 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#距离节点1两跳可以到达的节点集合\n",
    "#将其看成是无向图\n",
    "NodeVec = snap.TIntV()\n",
    "snap.GetNodesAtHop(graph, 1, 2, NodeVec, False)\n",
    "print(NodeVec.Len())\n",
    "#将其看成是有向图\n",
    "NodeVec = snap.TIntV()\n",
    "snap.GetNodesAtHop(graph, 1, 2, NodeVec, True)\n",
    "print(NodeVec.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n",
      "2\n",
      "CPU times: user 187 ms, sys: 159 ms, total: 346 ms\n",
      "Wall time: 342 ms\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#节点1和2的最短路径长度\n",
    "#将其看成是无向图\n",
    "print(snap.GetShortPath(graph,1,2,False))\n",
    "#将其看成是有向图\n",
    "print(snap.GetShortPath(graph,1,2,True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6.28662930888\n",
      "CPU times: user 8min 23s, sys: 805 ms, total: 8min 24s\n",
      "Wall time: 8min 24s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#最短路径分布的90-th percentile\n",
    "print(snap.GetAnfEffDiam(graph))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "14415513\n",
      "CPU times: user 1min 53s, sys: 705 ms, total: 1min 54s\n",
      "Wall time: 1min 54s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#以节点1为根节点得到到其他节点的树结构\n",
    "BfsTree = snap.GetBfsTree(graph, 1, True, False)\n",
    "# for EI in BfsTree.Edges():\n",
    "#     print \"Edge from %d to %d in generated tree.\" % (EI.GetSrcNId(), EI.GetDstNId())\n",
    "print(BfsTree.GetEdges())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%%time\n",
    "#基于NodeFrac节点的样本计算节点和边的中心性近似值集合\n",
    "Nodes = snap.TIntFltH()\n",
    "Edges = snap.TIntPrFltH()\n",
    "snap.GetBetweennessCentr(graph, Nodes, Edges, 1.0)\n",
    "# for node in Nodes:\n",
    "#     print \"node: %d centrality: %f\" % (node, Nodes[node])\n",
    "# for edge in Edges:\n",
    "#     print \"edge: (%d, %d) centrality: %f\" % (edge.GetVal1(), edge.GetVal2(), Edges[edge])\n",
    "print(Nodes.Len())\n",
    "print(Edges.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4.27710142534\n",
      "CPU times: user 7.49 s, sys: 49 ms, total: 7.54 s\n",
      "Wall time: 7.54 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#节点0的farness centrality\n",
    "print(snap.GetFarnessCentr(graph, 0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.233803200007\n",
      "CPU times: user 7.5 s, sys: 39 ms, total: 7.54 s\n",
      "Wall time: 7.54 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#节点0的closeness centrality：是farness centrality的倒数\n",
    "print(snap.GetClosenessCentr(graph, 0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4847571\n",
      "CPU times: user 53.9 s, sys: 113 ms, total: 54.1 s\n",
      "Wall time: 54.1 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算每个节点的PageRank分数集合\n",
    "PRankH = snap.TIntFltH()\n",
    "snap.GetPageRank(graph, PRankH)\n",
    "# for item in PRankH:\n",
    "#     print item, PRankH[item]\n",
    "print(PRankH.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4847571\n",
      "4847571\n",
      "CPU times: user 11min 31s, sys: 934 ms, total: 11min 32s\n",
      "Wall time: 11min 32s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算每个节点的Hubs和Authorities分数集合\n",
    "NIdHubH = snap.TIntFltH()\n",
    "NIdAuthH = snap.TIntFltH()\n",
    "snap.GetHits(graph, NIdHubH, NIdAuthH)\n",
    "# for item in NIdHubH:\n",
    "#     print item, NIdHubH[item]\n",
    "# for item in NIdAuthH:\n",
    "#     print item, NIdAuthH[item]\n",
    "print(NIdHubH.Len())\n",
    "print(NIdAuthH.Len())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "11\n",
      "14\n",
      "CPU times: user 38.5 s, sys: 82 ms, total: 38.6 s\n",
      "Wall time: 38.6 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#id为0这个节点的node eccentricity:节点偏心率，即从节点0到图中任何其他节点的最大最短路径距离\n",
    "#将其看成是无向图\n",
    "print(snap.GetNodeEcc(graph,0, False))\n",
    "#将其看成是有向图\n",
    "print(snap.GetNodeEcc(graph,0, True))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "405.583770644\n",
      "359.899654624\n",
      "332.924916517\n",
      "CPU times: user 10min 33s, sys: 911 ms, total: 10min 34s\n",
      "Wall time: 10min 34s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算有向图的邻接矩阵的SngVals最大奇异值。\n",
    "SngVals = 3\n",
    "SngValV = snap.TFltV()\n",
    "snap.GetSngVals(graph, SngVals, SngValV)\n",
    "for item in SngValV:\n",
    "    print item"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 3min 48s, sys: 306 ms, total: 3min 49s\n",
      "Wall time: 3min 49s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算有向图的邻接矩阵的左右奇异向量\n",
    "LeftSV = snap.TFltV()\n",
    "RightSV = snap.TFltV()\n",
    "snap.GetSngVec(graph, LeftSV, RightSV)\n",
    "# print \"Left singular vector:\"\n",
    "# for item in LeftSV:\n",
    "#     print item\n",
    "# print \"Right singular vector:\"\n",
    "# for item in RightSV:\n",
    "#     print item"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Core exists for K=100\n",
      "CPU times: user 36.4 s, sys: 249 ms, total: 36.7 s\n",
      "Wall time: 36.7 s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算K-score为K的网络集合\n",
    "K = 100\n",
    "KCore = snap.GetKCore(graph, K)\n",
    "if KCore.Empty():\n",
    "    print 'No Core exists for K=%d' % K\n",
    "else:\n",
    "    print 'Core exists for K=%d' % K"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 2min 13s, sys: 1.2 s, total: 2min 14s\n",
      "Wall time: 2min 14s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算得到每个K-score中的节点数\n",
    "CoreIDSzV = snap.TIntPrV()\n",
    "kValue = snap.GetKCoreNodes(graph, CoreIDSzV)\n",
    "# for item in CoreIDSzV:\n",
    "#     print \"order: %d nodes: %d\" % (item.GetVal1(), item.GetVal2())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 2min 32s, sys: 1.18 s, total: 2min 33s\n",
      "Wall time: 2min 33s\n"
     ]
    }
   ],
   "source": [
    "%%time\n",
    "#计算得到每个K-score中的边数\n",
    "CoreIDSzV = snap.TIntPrV()\n",
    "kValue = snap.GetKCoreEdges(graph, CoreIDSzV)\n",
    "# for item in CoreIDSzV:\n",
    "#     print \"order: %d edges: %d\" % (item.GetVal1(), item.GetVal2())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
